<template>
  <div class="oo">
    <!-- 内容 -->
    <div class="text" v-for="item in acTion" :key="item.id">
      <a class="p1" :href="item.target.url">{{ item.target.question.title }}</a>
      <div class="Img">
        <img :src="item.target.author.avatar_url" />
        <p>{{ item.target.question.author.name }}</p>
      </div>
      <p class="p2">{{ item.target.excerpt }}</p>
      <div class="Bottom">
        <div class="left">
          <p>{{ item.target.question.follower_count }}&nbsp;赞同</p>
          &nbsp;&nbsp;
          <p>.</p>
          &nbsp;&nbsp;
          <p>{{ item.target.question.answer_count }}&nbsp;评论</p>
        </div>
        <div @click="set(item.id)">
          <!-- <button  @click='show' @dblclick="hide">{{title}}</button> -->
            <el-button slot="reference">收藏</el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getTuijian } from "@/api";
export default {
  name: "Follow",
  data() {
    return {
      acTion: [],
      userinfo:{},
      // title:'收藏'
    };
  },
  mounted() {
    this.getDate();
    this.getInfo()
  },
  methods: {
    // 获取数据
    async getDate() {
      const result = await getTuijian();
      this.acTion = result.data.data;
    },
    // 将每一个点击的id
    set(id) {
      let info = this.acTion.find((item) => {
        return item.id === id;
      });
      // console.log(info);
      this.$store.commit("setInfo", info);
    },
    // 获取用户的信息
    getInfo(){
      if(!JSON.parse(localStorage.getItem('user'))){
        this.userinfo={}
      }
      this.userinfo=JSON.parse(localStorage.getItem('user'))
    },
  },
};
</script>

<style lang="less" scoped>
.oo {
  margin-top: 80px;
  .text {
    // margin-top: 50px;
    width: 100%;
    height: 100%;
    border-top: 10px solid rgb(238, 235, 235);
    .p1 {
      display: block;
      margin: 10px 0;
      margin-left: 10px;
      font-size: 20px;
      font-weight: bold;
      color: rgba(14, 13, 13, 0.933);
    }
    .Img {
      margin-left: 15px;
      display: flex;
      height: 30px;
      margin-bottom: 10px;
      img {
        width: 30px;
        height: 30px;
        border-radius: 50px;
      }
      p {
        margin-left: 5px;
        line-height: 30px;
      }
    }
    .p2 {
      margin-left: 10px;
      width: 350px;
      height: 60px;
      line-height: 30px;
      font-size: 18px;
      white-space: pre-wrap;
      display: -webkit-box;
      overflow: hidden;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
    }
    .Bottom {
      display: flex;
      width: 350px;
      margin-top: 10px;
      justify-content: space-between;
      padding: 10px;
      div {
        display: flex;
        .yuan {
          width: 6px;
          height: 6px;
          background-color: rgb(214, 210, 210);
          border-radius: 50px;
          margin-left: 5px;
        }
      }
      .left {
        width: 200px;
        p {
          font-size: 18px;
          color: rgb(182, 179, 179);
        }
      }
    }
  }
}
</style>
